using BepuPhysics;
using BepuPhysics.Collidables;

namespace Demos.Demos.Tanks
{
    /// <summary>
    /// 描述坦克部件的属性。
    /// </summary>
    public struct TankPartDescription
    {
        /// <summary>
        /// 此零件使用的形状索引是可碰撞的。
        /// </summary>
        public TypedIndex Shape;
        /// <summary>
        /// 这部分身体的惯性。
        /// </summary>
        public BodyInertia Inertia;
        /// <summary>
        /// 在坦克的局部空间中摆出零件的姿势。
        /// </summary>
        public RigidPose Pose;
        /// <summary>
        /// 要在副材料计算中使用的车身摩擦力。
        /// </summary>
        public float Friction;

        public static TankPartDescription Create<TShape>(float mass, in TShape shape, in RigidPose pose, float friction, Shapes shapes) where TShape : unmanaged, IConvexShape
        {
            TankPartDescription description;
            description.Shape = shapes.Add(shape);
            shape.ComputeInertia(mass, out description.Inertia);
            description.Pose = pose;
            description.Friction = friction;
            return description;
        }
    }
}
